package com.luo.dao.impl;

import com.luo.dao.HotMappers;
import com.luo.dao.SummaryMappers;
import com.luo.model.Order;
import com.luo.model.Summary;
import com.luo.model.recommend;
import com.luo.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;
import java.util.Map;

/**
 * 功能：
 * 作者：Luo。
 * 日期：2024/3/24 9:43
 */
public class SummaryDaoImpl implements SummaryMappers {
	@Override
	public int SubmitOrderController(Map map) {
		SqlSession sqlSession = SqlSessionUtil.getSqlSession();
		SummaryMappers mapper = sqlSession.getMapper(SummaryMappers.class);
		int row = mapper.SubmitOrderController(map);
		sqlSession.commit();
		sqlSession.close();
		return row;
	}

	@Override
	public Summary querySummaryById(String id) {
		SqlSession sqlSession = SqlSessionUtil.getSqlSession();
		SummaryMappers mapper = sqlSession.getMapper(SummaryMappers.class);
		Summary summary = mapper.querySummaryById(id);
		sqlSession.commit();
		sqlSession.close();
		return summary;
	}

	@Override
	public int updateSummaryStatusIs2(String id) {
		SqlSession sqlSession = SqlSessionUtil.getSqlSession();
		SummaryMappers mapper = sqlSession.getMapper(SummaryMappers.class);
		int row = mapper.updateSummaryStatusIs2(id);
		sqlSession.commit();
		sqlSession.close();
		return row;
	}

	@Override
	public int updateSummaryStatus(Map map) {
		SqlSession sqlSession = SqlSessionUtil.getSqlSession();
		SummaryMappers mapper = sqlSession.getMapper(SummaryMappers.class);
		int row = mapper.updateSummaryStatus(map);
		sqlSession.commit();
		sqlSession.close();
		return row;
	}

	@Override
	public List<Order> queryOrders(Map map) {
		SqlSession sqlSession = SqlSessionUtil.getSqlSession();
		SummaryMappers mapper = sqlSession.getMapper(SummaryMappers.class);
		List<Order> summaries = mapper.queryOrders(map);
		sqlSession.commit();
		sqlSession.close();
		return summaries;
	}

	@Override
	public int queryOrdersCount(Map map) {
		SqlSession sqlSession = SqlSessionUtil.getSqlSession();
		SummaryMappers mapper = sqlSession.getMapper(SummaryMappers.class);
		int count = mapper.queryOrdersCount(map);
		sqlSession.commit();
		sqlSession.close();
		return count;
	}
}
